package cn.edu.nju.software.util;

import java.util.Map;

import cn.edu.nju.software.bean.show.BookShow;

public class SessionOperator {

	@SuppressWarnings("unchecked")
	public static BookShow searchBookInSession(Map<String, Object> session, int bookID) {
		BookShow bookShow = null;
		Map<Integer, BookShow> booksMap = (Map<Integer, BookShow>) session.get("books");
		Map<Integer, BookShow> hotBooksMap = (Map<Integer, BookShow>) session.get("hotBooks");
		Map<Integer, BookShow> recentBooksMap = (Map<Integer, BookShow>) session.get("recentBooks");
		
		if (booksMap != null && ((bookShow = booksMap.get(bookID)) != null)) {
			return bookShow;
		} else if (hotBooksMap != null && ((bookShow = hotBooksMap.get(bookID)) != null)) {
			return bookShow;
		} else if (recentBooksMap != null && ((bookShow = recentBooksMap.get(bookID)) != null)) {
			return bookShow;
		} else {
			return null;
		}
	}
	
}
